#include "MyDevice.h"

DeviceContext::DeviceContext()
{
	ZeroMemory(&m_device_info, sizeof(TABLET_DEVICEINFO));
	m_recv_thread_handle = INVALID_HANDLE_VALUE;
	m_socket = 0;
}

DeviceContext::DeviceContext(SOCKET s, sockaddr_in addr, TABLET_DEVICEINFO &ti)
{
	m_socket = s;
	memcpy_s(&m_device_info, sizeof(TABLET_DEVICEINFO), &ti, sizeof(TABLET_DEVICEINFO));
}

DeviceContext::~DeviceContext()
{
	if (m_socket)
	{
		shutdown(m_socket, SD_BOTH);
		closesocket(m_socket);
		DWORD dwRet = WaitForSingleObject(m_recv_thread_handle, 2000);
		if (dwRet == WAIT_TIMEOUT)
		{

		}
		CloseHandle(m_recv_thread_handle);
		m_recv_thread_handle = INVALID_HANDLE_VALUE;
	}
}
